﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace RoofRunner.Actors.ActorComponents.Rendering
{
    public class RenderComponent : ActorComponent
    {
        #region Properties
        public Color Color { get; set; }

        public Matrix World { get; set; }

        public Texture2D Texture { get; set; }
        public String TextureRessourceName { get; set; }
        #endregion // Properties


        #region Constructors
        public RenderComponent() : this(null) { }
        public RenderComponent(String textureRessourceName) : this(textureRessourceName, new Color(255, 255, 255, 255)) { }
        public RenderComponent(String textureRessourceName, Color color)
        {
            this.Color = color;
            this.TextureRessourceName = textureRessourceName;
        }
        #endregion // Constructors


        #region Methods
        public override void LoadContent(ContentManager content)
        {
            if (this.TextureRessourceName != null) this.Texture = content.Load<Texture2D>(this.TextureRessourceName);
            base.LoadContent(content);
        }


        public override void PreRender(GameTime gameTime)
        {
            //this.World = Matrix.CreateWorld(this.Parent.Position, this.Parent.Forward, this.Parent.Up);
            this.World = Matrix.CreateScale(this.Parent.Scaling) * 
                Matrix.CreateTranslation(this.Parent.Position);

            base.PreRender(gameTime);
        }
        #endregion // Methods
    }
}
